import Vue from 'vue';
import VueRouter from 'vue-router';

//懒加载
const Login = () => import('@/views/users/login');
const ForwardPassword = () => import('@/views/users/forwardPassword');
const PersonalInfo = () => import('@/views/home/personalCenter/personInfo');
const ResetPassword = () => import('@/views/home/personalCenter/resetPassword');
const Home = () => import('@/views/home/index');
const HomeContent = () => import('@/views/home/home');
// const TenantManage = ()=> import('@/views/home/basicInfo/tenantManage')
// const TestSystem = ()=> import('@/views/home/basicInfo/testSystem')

const BusinessManage = ()=> import('@/views/home/configManage/businessManage/index')
const BusinessAdd = ()=> import('@/views/home/configManage/businessManage/add')
const BusinessEdit = ()=> import('@/views/home/configManage/businessManage/edit')
const BusinessView = ()=> import('@/views/home/configManage/businessManage/view')

const StorageConfig = ()=> import('@/views/home/configManage/storageConfig/index')
const StorageAdd = ()=> import('@/views/home/configManage/storageConfig/add')
const StorageEdit = ()=> import('@/views/home/configManage/storageConfig/edit')
const StorageView = ()=> import('@/views/home/configManage/storageConfig/view')

const SystemSetting = ()=> import('@/views/home/configManage/systemSetting/index')
const SystemAdd = ()=> import('@/views/home/configManage/systemSetting/add')
const SystemEdit = ()=> import('@/views/home/configManage/systemSetting/edit')
const SystemView = ()=> import('@/views/home/configManage/systemSetting/view')

const TransmissionConfig = ()=> import('@/views/home/configManage/transmissionConfig/index')
const TransmissionAdd = ()=> import('@/views/home/configManage/transmissionConfig/add')
const TransmissionEdit = ()=> import('@/views/home/configManage/transmissionConfig/edit')
const TransmissionView = ()=> import('@/views/home/configManage/transmissionConfig/view')

const FileRecord =() => import('@/views/home/contentManage/fileRecord/index')
const FileView =() => import('@/views/home/contentManage/fileRecord/view')

const error = ()=> import('@/views/404')


//1.安装插件
Vue.use(VueRouter);

//2. 创建router
const routes = [
  // 根路径
  {
    path:'/',
    redirect: {path: '/login'}
  },
  // 登录
  {
    path:'/login',
    component:Login,
    meta: {auth:true}
  },
  // 忘记密码
  {
    path: '/forwardPassword',
    component:ForwardPassword,
    meta: {auth:true}
  },
  {
    path: '/homeContent',
    component: Home,
    meta: {title: '首页', path: '/home'},
    children:[
      // 首页
      {
        path:'/home',
        name:'homeContent',
        component:HomeContent,
      },
      // 个人信息
      {
        path:'/personInfo',
        name:'personalInfo',
        component:PersonalInfo,
        meta: {title: '个人信息'}
      },
      // 修改密码
      {
        path:'/resetPassword',
        name:'resetPassword',
        component:ResetPassword,
        meta: {title: '修改密码'}
      },
      // 业务管理
      {
        //业务管理主页
        path: '/configManage/businessManage',
        name:'businessManage',
        component: BusinessManage,
        meta: {title: '业务管理' , path:'/configManage/businessManage'},
        children:[
          // 业务增加
          {
            path:'/configManage/businessAdd',
            name:'businessAdd',
            component:BusinessAdd,
            meta:{title: '增加'},
          },
          // 业务编辑
          {
            path:'/configManage/businessEdit',
            name:'businessEdit',
            component:BusinessEdit,
            meta: {title: '编辑'}
          },
          // 业务查看
          {
            path:'/configManage/businessView',
            name:'businessView',
            component:BusinessView,
            meta: {title: '查看'}
          }
        ]
      },
      // 存储配置
      {
        //存储配置主页
        path: '/configManage/storageConfig',
        name:'storageConfig',
        component: StorageConfig,
        meta: {title: '存储配置' , path:'/configManage/storageConfig'},
        children:[
          // 存储配置增加
          {
            path:'/configManage/storageAdd',
            name:'storageAdd',
            component:StorageAdd,
            meta:{title: '增加'},
          },
          // 存储配置编辑
          {
            path:'/configManage/storageEdit',
            name:'storageEdit',
            component:StorageEdit,
            meta: {title: '编辑'}
          },
          // 存储配置查看
          {
            path:'/configManage/storageView',
            name:'storageView',
            component:StorageView,
            meta: {title: '查看'}
          }
        ]
      },
      // 系统设置
      {
        path: '/configManage/systemSetting',
        name:'systemSetting',
        component: SystemSetting,
        meta: {title: '系统设置' , path:'/configManage/systemSetting'},
        children:[
          // 系统新增
          {
            path:'/configManage/systemAdd',
            name:'systemAdd',
            component:SystemAdd,
            meta: {title:'系统新增'}
          },
          // 系统编辑
          {
            path:'/configManage/systemEdit',
            name:'systemEdit',
            component:SystemEdit,
            meta:{title:'系统编辑'}
          },
          // 系统查看
          {
            path:'/configManage/systemView',
            name:'systemView',
            component:SystemView,
            meta:{title:'系统查看'}
          }
        ]
      },
      //传输配置
      {
        //传输配置主页
        path: '/configManage/transmissionConfig',
        name:'transmissionConfig',
        component: TransmissionConfig,
        meta: {title: '传输配置' , path:'/configManage/transmissionConfig'},
        children:[
          // 传输配置增加
          {
            path:'/configManage/transmissionAdd',
            name:'transmissionAdd',
            component:TransmissionAdd,
            meta:{title: '增加'},
          },
          // 传输配置编辑
          {
            path:'/configManage/transmissionEdit',
            name:'transmissionEdit',
            component:TransmissionEdit,
            meta: {title: '编辑'}
          },
          // 传输配置查看
          {
            path:'/configManage/transmissionView',
            name:'transmissionView',
            component:TransmissionView,
            meta: {title: '查看', path:'/configManage/transmissionView'},
          }
        ]
      },
      // 文件记录
      {
        // 文件记录主页
        path: '/contentManage/fileRecord',
        name: 'fileRecord',
        component:FileRecord,
        meta: {title: '操作记录',path: '/contentManage/fileRecord'},
        children: [
            // 查看
          {
            path: '/contentManage/fileView',
            name: 'fileView',
            component:FileView,
            meta: {title: '查看'}
          }
        ]
      }
    ]
  },

  {
    path: '*',
    name:'error',
    component:error
  }
]
const router = new VueRouter({
  routes,
  mode:'history',
});

export default router;
